<?php

// +----------------------------------------------------------------------
// | Description: 公共函数库
// | Author:      李大明
// | Email:       limingnk@qq.com
// | DateTime:    2016-07-20 20:59:58
// +----------------------------------------------------------------------

//curl post
function curl_post($url, $message_text) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $message_text);
	$result = curl_exec($ch);
	curl_close($ch);
	return $result;
}

//curl get
function curl_get($url) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回文本流,
	$data = jsondecode(curl_exec($ch), true);
	curl_close($ch);
	return $data;
}
